/*
 * @Author: your name
 * @Date: 2021-12-28 11:22:19
 * @LastEditTime: 2022-05-17 20:54:07
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /medical-plugin-dvp/app.js
 */
// app.js
App({
  data:{
    extraData:""
  },
  onLaunch(options) {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
   
    

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  onShow(options){
    const updateManager = wx.getUpdateManager()
    
    updateManager.onCheckForUpdate(function (res) {
        // 请求完新版本信息的回调
        console.log(res.hasUpdate)
    })

    updateManager.onUpdateReady(function () {
        wx.showModal({
            title: '更新提示',
            content: '新版本已经准备好，是否重启应用？',
            success: function (res) {
                if (res.confirm) {
                    // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
                    updateManager.applyUpdate()
                }
            }
          })
    })

    updateManager.onUpdateFailed(function () {
      // 新版本下载失败
    })
    var extraData=null
    console.log("options",options)
    let getLaunchOptionsSync =  wx.getLaunchOptionsSync();
    if (getLaunchOptionsSync.scene == '1037') {
      let {check_in_id, person_id, customer_id, user_type, doctor_id} = options.query;
      this.globalData.miniProgramParams.check_in_id = check_in_id;
      this.globalData.miniProgramParams.person_id = person_id;
      this.globalData.miniProgramParams.customer_id = customer_id;
      this.globalData.miniProgramParams.user_type = user_type;
      this.globalData.miniProgramParams.doctor_id = doctor_id;
    }else {
      this.data.options = options;
    }
  },
  globalData: {
    userInfo: null,
    cfImgArray: [],
    checkReport: [],
    pluginID: 'wx16c953bdb451ff30',
    pharmacyUserphone: '',
    tenant_id: '',
    operator_id: '',
    openid: '',
    customer_id: '',
    person_info: {},
    tenant_settings:{},
    selectZhongList: [],
    environment: 'dvp',
    // environment: 'test',
    
    miniProgramParams:{}
  }
})
